<?php

/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Smarty number format modifier plugin
*
* Type: modifier<br>
* Name: number_format<br>
* Purpose: format number via currency
* @param string
* @param integer
* @param character
* @param character
* @return string
*/

function smarty_modifier_number_format($number, $decimals="0", $decpoint=".", $thousandsep=",")
{
	if ($number == "0"){
		return '0';
	}
	if ($number < 0){
		$return = "(".number_format($number, $decimals, $decpoint, $thousandsep).")";
	}else{
		$return = number_format($number, $decimals, $decpoint, $thousandsep);
	}
	if ($return == 0){
		return "";
	}else{
		return $return;
	}
}

/* vim: set expandtab: */

?>
